<template>
    <page-header-wrapper>
        <a-card :bordered="false" style="margin-bottom: 20px" title="搜索查询">
            <div class="table-page-search-wrapper">
                <a-form layout="inline">
                    <a-form-item label="操作类型">
                        <!-- <a-input v-model="queryParam.title"></a-input> -->
                        <a-select placeholder="请选择" v-model="queryParam.title" style="width: 200px">
                            <a-select-option  value="">全部</a-select-option>
                          <a-select-option v-for="(item, i) in logSearch" :key="item.title" :value="item.title">{{item.title}}</a-select-option>
                        </a-select>
                    </a-form-item>
                    <a-form-item label="登录时间" style="margin-left: 10px">
                        <a-date-picker v-model="queryParam.createTime"
                                       format="YYYY-MM-DD"
                                       @change="handleChangeStartTime"/>
                    </a-form-item>
                    <a-form-item label="">
                        <a-button style="margin-left: 10px" type="primary"
                                  @click="onSearch">
                            查询
                        </a-button>
                        <a-button style="margin-left: 10px"
                                  @click="onReset">
                            重置
                        </a-button>
                    </a-form-item>
                </a-form>
            </div>
        </a-card>
        <a-card :bordered="false">
            <a-table
                :columns="columns"
                :data-source="tableData"
                :loading="tableLoading"
                :pagination="pagination"
                :rowSelection="rowSelection"
                :scroll="{ x: '100%' }"
                rowKey="id"
                @change="handleChange"
            >
            </a-table>
        </a-card>
    </page-header-wrapper>
</template>
<script>
import basic from '@/mixins/basic'
import { getHandleLog, getLogSearch } from '@/api/api'

export default {
    mixins: [basic],
    data() {
        return {
            request: {
                page: getHandleLog
            },
            queryParam: {
                title: '',
                createTime: ''
            },
            resetQueryParam: {},
            columns: [
                {
                    title: 'ip',
                    dataIndex: 'ip'
                },
                {
                    title: '操作记录内容',
                    dataIndex: 'remark'
                },
                {
                    title: '操作类型',
                    dataIndex: 'title'
                },
                {
                    title: '操作人',
                    dataIndex: 'createBy'
                },
                {
                    title: '操作时间',
                    dataIndex: 'createTime'
                },
            ],
            tableData: [],
            timeDate: [],
            logSearch: []
        }
    },
    created() {
        this.getLogSearch()
    },
    methods: {
        handleChangeStartTime(value1, value2) {
            console.log(value1, value2)
            this.queryParam.createTime = value2
        },
        getLogSearch() {
            getLogSearch().then(res => {
                this.logSearch = res
            })
        }
    }
}
</script>
